package com.lianjinsu.shop.controller;

import com.lianjinsu.shop.controller.vo.Response;
import com.lianjinsu.shop.entity.Admin;
import com.lianjinsu.shop.service.AdminService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin")
@RequiredArgsConstructor
public class AdminController {
    private final AdminService adminService;

    @GetMapping("query/id")
    Response<Admin> query(@PathVariable int id) {
        return Response.ok(adminService.query(id));
    }

    @PostMapping("insert")
    Response<Boolean> insert(@RequestBody Admin admin) {
        return Response.ok(adminService.insertOrUpdate(admin));
    }
}
